<template>
  <div class="logs">
    <div class="b-f p-l p-r p-t">
      <SearchComp
        :searchForm="searchForm"
        :searchData="searchData"
        :searchAction="searchAction"
      ></SearchComp>
    </div>

    <div class="b-p-f m-t">
      <TableComp
        ref="multipleTable"
        :tableData="tableData"
        :tableConfig="tableConfig"
        :isSelect="false"
        :isIndex="true"
        :isShowPage="true"
        :queryParams="queryParams"
        @getPagination="getList"
      ></TableComp>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      multipleSelection: [],
      queryParams: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
      },
      tableData: [],
      tableConfig: [
        {
          prop: "remark",
          label: "方法名",
        },
        {
          prop: "url",
          label: "请求路径",
        },
        {
          prop: "method",
          label: "请求方式",
        },

        {
          prop: "requestParam",
          label: "入参",
        },
        {
          prop: "clientIp",
          label: "ip",
        },
        {
          prop: "response",
          label: "返回",
        },
        {
          prop: "beginTime",
          label: "请求开始时间",
        },
        {
          prop: "operator",
          label: "操作人",
        },
      ],
      searchData: {
        operator: "",
        method: "",
      },
      searchForm: {
        changeMethod: () => this.getList(),
        formData: [
          {
            type: "Input",
            label: "操作人",
            prop: "operator",
            clearable: true,
            icon: "el-icon-search",
            placeholder: "请输入",
          },
          {
            type: "Input",
            label: "方法名",
            prop: "remark",
            clearable: true,
            icon: "el-icon-search",
            placeholder: "请输入",
          },
        ],
      },
      searchAction: [
        {
          label: "查找",
          type: "primary",
          handle: () => {
            this.getList();
          },
        },
        {
          label: "重置",
          type: "primary",
          plain: true,
          handle: () => {
            this.queryString = {
              operator: "",
              method: "",
            };
            this.getList();
          },
        },
      ],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      let params = {
        pageNum: this.queryParams.currentPage,
        pageSize: this.queryParams.pageSize,
        ...this.searchData,
      };
      this.$axios
        .post(this.$api.setting.logApi.getLogList, params)
        .then((res) => {
          const { data, code } = res.data;
          if (code == 200) {
            this.tableData = data.rows;
            this.queryParams.total = data.total;
          }
        });
    },
  },
};
</script>

<style lang="scss" scoped></style>
